/*
**  author: wd
**  create: 2015/08/22
*/

#ifndef __CSV_DATA_MGR_H__
#define __CSV_DATA_MGR_H__

#include "comm.h"
#include "Singleton.h"
#include <map>
#include <vector>
#include "AliasRandom.h"

struct csv_store_t
{
	int		index;
	int		golds;
	int		gems;
};



struct csv_private_chips_t
{
	int		small_chip;
	int		max_chip;
	int		chap1;
	int		chap2;
	int		chap3;
	int		chap4;
	int		chap5;
};


class CsvDataMgr :  public Singleton<CsvDataMgr>
{
public:

	CsvDataMgr();
	~CsvDataMgr();

	bool Init();
	void ShutDown();

	bool LoadStoreCSV();
	void ReleaseStoreCSV();

	bool LoadBroadcastCharNameStringCSV();
	bool LoadBroadcastChatMsgCSV();

	bool LoadPrivateChipCsv();
	void ReleasePrivateChipCsv();

	bool LoadTigerCsv();

	csv_store_t * GetStoreInfo(int index);

	csv_private_chips_t * GetPrivateChips(int small_bet, int max_bet);

	int	 GetTigerRandomType(int curSorce);



	std::string GetRandomWomanName();
	std::string GetRandomManName();
	std::string GetRandomWomanChatMsg(int weekday);
	std::string GetRandomManChatMsg(int weekday);

	int gb2312toutf8(char *sourcebuf,size_t sourcelen,char *destbuf,size_t destlen); 

protected:
	typedef std::map<int, csv_store_t *>	CSV_STORE_MAP;
	typedef std::vector< std::string >		STD_STRING_VEC;
	typedef std::map<int, csv_private_chips_t * >  CSV_PRIVATE_MAP;
	typedef std::map< int, CSV_PRIVATE_MAP >	CSV_ALL_CHIPS_MAP;

	bool			m_is_load;
	CSV_STORE_MAP	m_stores_;

	STD_STRING_VEC	m_woman_names_;
	STD_STRING_VEC	m_man_names_;

	STD_STRING_VEC	m_woman_chat_msgs_[7];
	STD_STRING_VEC	m_man_chat_msgs_[7];	

	CSV_ALL_CHIPS_MAP	m_private_chips_;

	Alias			m_alias_one_;
	Alias			m_alias_two_;
	Alias			m_alias_three_;
	int				m_tiger_one_start_;
	int				m_tiger_one_end_;
	int				m_tiger_two_start_;
	int				m_tiger_two_end_;
	int				m_tiger_three_start_;
	int				m_tiger_three_end_;
};

extern CsvDataMgr * g_csvmgr;

#endif // __CSV_DATA_MGR_H__

